function onAddNewUser(frmID, msgDiv, listtable)
{
	var newId = '';
	
	$(frmID).request(
		{
			asynchronous: false,
			parameters: $(frmID).serialize(true),
	  		onComplete: function(transport)
	  		{ 
			  	var response = transport.responseText || "";
		    	
		    	$(msgDiv).innerHTML = '';
		    	
//		    	alert(response);
		    	
		    	if(response != "")
		    	{
		    		obj = response.evalJSON();
		    		
		    		if(obj == null)
		    		{
		    			$(msgDiv).update('Something wrong! Reponsed string is: ' + response);
		    		}
		    		
			    	if(msgDiv != null)
				    	$(msgDiv).update(obj.message);
				    
				    if(listtable != null && $(listtable) != null)
				    {
				    	if(obj.code == 0)
				    	{
					    	//repair new row used to add to table
						   	str = '<tr id="user-' + obj.ID + '" class="newrow">';
							str += '	<th scope="row" style="text-align: center">' + obj.ID + '</th>';
							str += '	<td>' + obj.user_login + '</td>';
							str += '	<td>' + obj.user_nicename + '</td>';
							str += '	<td align="center">' + obj.user_email + '</td>';
							str += '	<td align="center">' + obj.user_url + '</td>';
							str += '	<td><a href="?mod=userman&sub1=edituser&id=' + obj.ID + '" class="edit">' + obj.sEdit + '</td>';
							str += '	<td><a onclick="" class="delete">' + obj.sDelete + '</td>';
							str += '</tr>';
							
							$(listtable).innerHTML += str;
							
							newId = 'user-' + obj.ID;
				    	}
				    }
		    	}
	  		}
		});

	$(msgDiv).style.display = 'block';
	Fat.fade_element(msgDiv, null, 1500, null, null);
	if(newId != '')
		Fat.fade_element(newId);
	//revent submit page
	return false;
}

function onDeleteUser(url, resp, UserId)
{
	var isOK = -1;
	
	if(!confirm('Are you sure you want to delete the user with Id:' + UserId))
	{
		return false;
	}
	
	new Ajax.Request(url, 
	{
	  method: 'post',
	  asynchronous: false,
	  parameters:'act=deluser&id=' + UserId,
	  onSuccess: function(transport) 
  		{
			var response = transport.responseText.trim();
			
			//alert(response);
			
			obj = response.evalJSON();

    		if(obj == null)
    		{
    			$(resp).innerHTML = 'Something wrong! Reponsed string is: ' + response;
    		}
    		
    		isOK = obj.code;
		
    		$(resp).update(obj.message);
		}
	});

	$(resp).style.display = 'inherit';
	Fat.fade_element(resp, null, 1500, null, null);

	if(isOK == 0)
	{
		rowID = 'user-' + UserId;
		Fat.fade_element(rowID, null, 1000, "#f22", null);
		setTimeout("$(rowID).remove()", 1000);
		
	}				
}